package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.Customer;
import com.atguigu.jxc.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author zjr
 * @version 1.0
 */
@RestController
@RequestMapping("/customer/")
public class CustomerController {
    @Autowired
    CustomerService service;

    @PostMapping("list")
    public Map<String, Object> customerList(Integer page, Integer rows,
                                            @RequestParam(value = "customerName", required = false) String customerName) {
        return service.customerList(page, rows, customerName);
    }

    @PostMapping("save")
    public ServiceVO saveCustomer(Customer customer,
                                  @RequestParam(value = "customerId", required = false) Integer customerId) {
        return service.saveCustomer(customer, customerId);
    }

    @RequestMapping("delete")
    public ServiceVO deleteCustomer(String ids){
        return service.deleteCustomer(ids);
    }
}
